package practice_0527;

public class practice03 {
    public static void main(String[] args) {
        Thread thread = new Thread(new ThreadDemon());
        thread.setDaemon(true);
        thread.start();
        for (int i = 0; i < 5; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("i=" + i);

        }
        System.out.println("主线程退出....");
    }
}
class ThreadDemon implements Runnable{

    @Override
    public void run() {
        while(true){
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("守护线程运行中....");

        }

    }
}